home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / admin-v1.000 / admin-v1 / duck < prev    next >
Text File  |  1995-05-20  |  962b  |  44 lines

  1. #!/bin/sh
  2. #
  3. # check for users with lots of disk space used
  4. #
  5. MINUSERID=500        # where your uids start
  6.             # (lowest "regular user")
  7. MAXSIZE=8192        # max number of 512 byte blocks for trigger
  8.             # (1024 * (Megabytes) = MAXSIZE)
  9. #
  10. # uncomment only one of the following two lines:
  11. PASSWD="cat /etc/passwd"    # if not using NIS
  12. # PASSWD="ypcat passwd"        # if using NIS
  13.  
  14. HOST=`hostname`
  15. TMP=/tmp/duck.$$
  16. rm -f $TMP
  17.  
  18. DFCOMMAND=/bin/df        
  19.  
  20. touch $TMP
  21. for i in `$PASSWD | awk -F: '{if ($3 > '$MINUSERID') print $6}'`
  22. do
  23.    cd $i
  24.    x=`$DFCOMMAND . | grep "^/"`
  25.    if [ "$x" != "" ]; then    # if local to this host
  26.       size=`du -s . | awk '{print $1}'`
  27.       if [ $size -gt $MAXSIZE ]; then
  28.          echo "$i ($size)" >>$TMP
  29.       fi
  30.    fi
  31. done
  32.  
  33. n=`wc -l $TMP | awk '{print $1}'`
  34. if [ $n -gt 0 ]; then
  35.    echo " "
  36.    echo "User directories on $HOST larger than $MAXSIZE 512-byte blocks:"
  37.    echo " "
  38.    sed 's/^/     /' $TMP
  39.    echo " "
  40. fi
  41. /bin/cp $TMP /tmp/user.chk
  42. rm -f $TMP
  43.  
  44.